home *** CD-ROM | disk | FTP | other *** search
- Logo Instructions.
-
- Logo is a language developed for school children by
- Seymour Papert. It encourages them to interact more
- eagerly and more easily with the computer.
-
- The Logo language consists of two parts: there is the list
- handling section and the far more widely used Turtle
- Graphics section. It is the Turtle Graphics which you have
- here.
-
- Turtle Graphics will allow you to create a variety of
- different patterns on the screen as well as introduce you
- to good programming practice.
-
- In addition it will allow you to create an almost
- "intelligent" Turtle as well as use the Turtle to plot
- graphs.
-
- Logo is considered such an important language in allowing
- children to build up confidence in the computer that it is
- quoted in several places in the National Curriculum ,
- Mathematics document. The version which you have purchased
- will allow you to do develop all the Logo ideas described
- in that document.
-
- Getting Started:
-
- Insert the disc in the logged disc drive, type LOGO and
- press return. The disc must have Logo.exe and Logo.dat in
- the same directory. All your files will also be stored in
- this directory.
-
- Now that you are into Logo you have the ? prompt. This is
- to remind you that you are now in charge of the Turtle-
- that is the little triangle in the middle of the screen.
- That is its Home and when you type Home that is where it
- will go.
-
- Now enter a command such as FORWARD 100 or FD 100 for
- short, and press return. This tells the Turtle to move
- forward by 100 steps. Commands can be in UPPER or lower
- case. All commands should have a space after them.
-
-
- We can make it turn right by 90 degrees with RIGHT 90 or RT
- 90. LEFT 27 or LT 27 will turn it 27 degrees to the left.
-
- Sometimes we don't want the Turtle to be visible. When
- invisible it does draw faster. We can hide the Turtle with
- HT and make it show again with ST.
-
- By now you know enough Logo to draw some simple patterns.
- Draw some. If you make a small mistake use PE to turn the
- Turtle pen into an eraser to rub out the line and then
- SETPC 15 to change it back into a pen that draws.
-
- If you make a terrible mess of the screen then type CLEAN
- to clean the screen. If you want to move the Turtle to a
- new spot on the screen without it drawing then use PU for
- pen up then use PD when you want it to draw again.
-
- The screen you are working on measures 2000 units by 2000
- units. The centre of the screen has co-ordinates 0,0.
-
- You can use SETX -123 to put the Turtle at position X=-123
- and SETY -234 to put it at position Y=-234. You can also
- use SETPOS -123 -234 to place the Turtle at the same
- position. To find out where you are on the screen type:
- PR POS
-
- The Turtle cannot leave the screen unless you give it
- permission. It sees a fence right round the screen. If you
- try and go FORWARD 3000 then it will say "That is over the
- fence."
-
- To allow the Turtle to escape you can use the command
- WRAP. This allows the Turtle to disappear of one side of
- the screen and immediately reappear on the opposite side
- of the screen. It is as if the screen were a sphere.
-
- The other method of letting the Turtle leave the screen is
- to give it the command WINDOW. This allows the Turtle to
- go anywhere but you can only see it when it appears in
- front of the window which is the screen.
-
- Now we can draw simple patterns. To draw a square you need
- the following commands:
- CS
- FD 200
- RT 90
- FD 200
- RT 90
- FD 200
- RT 90
- FD 200
- RT 90
- which is very slow to type every time you want a square.
-
- Instead we can reduce that to:
- CS
- REP 4[FD 200 RT 90]
- This is short for repeat four times the section in square
- brackets. This will produce a square.
-
- We can have brackets inside brackets. For example try:
- CS
- REP 4[FD 200 RT 90 REP 4[FD 80 LT 90]]
- Even that can be bit of a handful if we have to type it
- regularly so instead we can write a procedure.
-
- Procedures
-
- These can be thought of as short programs. To write a
- procedure to draw a square type:
- TO Square and press return.
- The prompt has changed from a ? to a > showing you that
- you are in the editor and not controlling the Turtle.
- Enter the lines :
- REP 4[FD 100 RT 90]
- END
-
- The last line has told the computer that you have finished
- with the editor and you now wish to have control over the
- Turtle again You could have just pressed return rather
- than type the word end.
-
- This time to draw that square all you have to do is to
- type Square and the Turtle will carry out the procedure
- Square.
-
- We can demonstrate this with:
- CS REP 18[Square RT 20 FD 40]
-
- You could have called it any name you wanted to but square
- seems sensible.
-
- It is possible to make further improvements to this
- procedure. This time enter:
-
- TO Sqsz :Size
- REP 4 [FD :Size RT 90]
- END
-
- To get this procedure to work you will have to give the
- variable Size a value. We do this when we call the
- procedure Sqsz by entering:
- CS Sqsz 200
-
- This puts the value 200 into the variable Size and then
- draws a square of size 200.
-
- Try the following:
- CS
- MAKE "Size 10
- REP 20 [Sqsz :Size MAKE "Size :Size+20]
-
- Pretty isn't it?
-
- The Logo Commands
-
- PR is the command to print. It is introduced first of all
- because it is used in so many of the following examples. It
- can be entered in its full form as PRINT.
-
- ABS As in PR ABS -3 gives the absolute value of the
- input number. In this case it will output 3.
-
- AND As in PR AND 3<4 7>4 prints TRUE if both
- conditions are true.
-
- ARC As in ARC 0 0 100 180 270 draws an arc at
- position 0,0 of radius 100 units from heading 180 to 270.
- If negative numbers are use for the start and finish then
- the arc is drawn as a slice of pie.
- eg ARC 0 0 100 -180 -270
-
- ASCII As in PR ASCII "A prints the ASCII value of the
- first letter. In this case it will be 65.
-
- ATN As in PR ATN 2 outputs the arctangent (inverse of
- tangent) in degrees. In this case it prints the angle that
- has a tangent of 2.
-
- BACK or BK As in BACK 100. Moves the Turtle back 100 units.
-
- BYE Leaves the current session of Logo.
-
- CHAR As in PR CHAR 82 prints the letter corresponding
- to ASCII code 82.
-
- CIRCLE As in CIRCLE 0 0 100 draws a circle of radius 100
- and centre at 0,0 -the centre of the screen. It does not
- move the Turtle. eg
- MAKE "R 10
- REPEAT 20[CIRCLE :r*~1 :r*~1 :r MAKE "r :r+10]
- Note that unary negative is ~ not - as in ~2 for minus 2.
-
- CLEAN Erases the contents of the viewport but without
- affecting the Turtle.
-
- COS As in PR COS 20 outputs the cosine of the angle
- (which is entered in degrees).
-
- CS This is short for clear screen. It erases the
- contents of the viewport and places the Turtle at 0,0 and
- on a heading of 0.
-
- CT This is short for clear text. Erases the contents
- of the text window and places the cursor in the top left
- hand corner.
-
- DEGREES As in PR DEGREES 25 prints out the number of
- degrees in the entered number of radians.
-
- DIR As in DIR outputs all the files with a .LOG
- suffix in the current drive and directory.
-
- DOT As in DOT 50 50 which places a dot at 50,50
- without moving the Turtle. PE followed by DOT will erase a
- point.
-
- EDALL Loads all the procedures and variables in the
- workspace into the text editor. To leave the editor use
- the ESCape key.
-
- EDIT or ED As in ED "Pat loads the specified procedure into
- the text editor.
-
- END Indicates the end of a procedure.
-
- ERALL Erases all the procedures and variables from the
- workspace.
-
- FENCE Limits the Turtle to the screen. It also warns
- you if the Turtle is out of bounds.
-
- FILL As in FILL 3. Fills the area around the Turtle
- with colour 3.
-
- FORWARD or FD As in FORWARD 100 moves the Turtle forward by
- 100 units.
-
- HEADING As in PR HEADING prints out the Turtle's heading.
-
- HOME Returns the Turtle to the Home position of 0,0
- and with heading 0(North).
-
- HT This is short for hide Turtle. It makes the
- Turtle invisible and speeds up drawing.
-
- IF As in
- IF :A>:B [PR [:A is bigger]] [PR [:A is not bigger]]
- If the condition is true the first command is carried out.
- If not true the second command is carried out if it is
- present. The conditional statement can contain <, > or =
- but not combinations of them.
-
- INT As in PR INT 3.34 which prints the integer
- portion of 3.34 which is 3.
-
- LEFT or LT As in LT 90 which turns the Turtle 90 to the
- left. All angles are in degrees.
-
- LOAD As in LOAD "Mine which loads the procedures and
- variables in Mine into the workspace.
-
- LN As in PR LN 2 which prints the natural log of the
- number.
-
- MAKE As in MAKE "Side 50 which places 50 into the
- variable Side. This is now a global variable. The following
- are correct syntax:
- MAKE "A SIN(34)
- Make "A LN(34.5)
- Note that calculations should not contain spaces.
-
- NOT As in PR NOT(3=4) which prints True since the
- expression is false.
-
- OR As in PR OR (1=2) (1=1) which prints True since
- the one of the two conditions is true.
-
- PENDOWN or PD Puts the Turtle pen down to resume drawing
- after a PE or PU command.
-
- PENERASE or PE Makes the Turtle pen into an eraser by
- making it draw in the background colour.
-
- PENUP or PU Picks the Turtle pen up so that the Turtle can
- be moved without affecting the drawing. Try
- REP 4[ REP 10 [FD 20 PU FD 20 PD] RT 90]
-
- POS As in PR POS prints the position of the Turtle.
-
- PRINT or PR As in PR "Me prints Me.
-
- PROD As in PR PROD 2 3 or PR PROD 2 3 4 which prints
- the product of the numbers which follow.
-
- QUOT As in PR QUOT 24 7 which outputs the integer part
- of the division. In this case 3.
-
- RADIANS As in PR RADIANS 90 which will output the number
- of radians which was entered as degrees.
-
- RANDOM As in PR RANDOM 20 which prints out a random
- number between 1 and 20.
-
- REMAINDER As in PR REMAINDER 7 3 which prints out the
- remainder of 7 divided by 3.
-
- REPEAT or REP As in REP 4[ FD 100 RT 90] which repeats the
- instructions in the square brackets 4 times.
-
- RIGHT or RT As in RT 90 which turns the Turtle right by 90
- degrees.
-
- ROUND As in PR ROUND 3.5 which rounds the input number
- to the nearest integer- in this case 4.
-
- SAVE As in SAVE "Mine which will save all the
- procedures and variables to the file Mine. It is possible
- to put a path before it to save it to a different disc or
- drive.
-
- SETBG As in SETBG 2 followed by CS which will then set
- the background to the new colour.
-
- SETH As in SETH 45 which sets the Turtle heading to 45
- degrees.
-
- SETPC As in SETPC 3 which sets the pencolour to colour
- 3.
-
- SETPOS As in SETPOS 50 50 which puts the Turtle at co-
- ordinates 50,50
-
- SETX As in SETX 100 moves the Turtle horizontally to X
- co-ordinate 100.
-
- SETY As in SETY 100 moves the Turtle vertically to Y
- co-ordinate 100.
-
- SHOWTURTLE or ST Makes the Turtle visible if it has been
- hidden with HT.
-
- SIN As in PR SIN 30 which outputs the sine of the
- angle which was input in degrees.
-
- SQRT As in PR SQRT 64 which will print out the square
- root of 64 being 8.
-
- SUM As in PR SUM 2 2 which will print out the sum of
- the numbers which follow.
-
- TAN As in PR TAN 45 which will print out the Tangent
- of 45 degrees.
-
- TO As in TO Sq being the first line of the procedure
- called Sq.
-
- TOWARDS As in PR TOWARDS 50 75 which will print the
- heading for the Turtle to move towards co-ordinates 50,75.
-
- WINDOW Allows the Turtle to move anywhere but if it
- leaves the screen area it will not be visible.
-
- WRAP Allows the Turtle to treat the screen as a
- sphere. When it disappears from one side it will reappear
- on the opposite side of the screen.
-
- XCOR As in PR XCOR will print the X co-ordinate of the
- Turtle
-
- YCOR As in PR YCOR will print the Y co-ordinate of the
- Turtle.